package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 工单服务项
 * </p>
 *
 * @author linan
 * @date 2022-10-19
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOrderServiceItemDisposalModeEnum", description = "处理方式 #{CONSTRUCTION_AND_INSTALLATION:施工安装;EQUIPMENT_WARRANTY:设备保修;SITE_ACCEPTANCE:场地验收;OVERTIME_ON_SITE:现场加班;OTHER:其他-枚举")
public enum WorkOrderServiceItemDisposalModeEnum implements BaseEnum {

    /**
     * CONSTRUCTION_AND_INSTALLATION="施工安装"
     */
    CONSTRUCTION_AND_INSTALLATION("施工安装"),
    /**
     * EQUIPMENT_WARRANTY="设备保修"
     */
    EQUIPMENT_WARRANTY("设备保修"),
    /**
     * SITE_ACCEPTANCE="场地验收"
     */
    SITE_ACCEPTANCE("场地验收"),
    /**
     * OVERTIME_ON_SITE="现场加班"
     */
    OVERTIME_ON_SITE("现场加班"),
    /**
     * OTHER="其他"
     */
    OTHER("其他"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOrderServiceItemDisposalModeEnum match(String val, WorkOrderServiceItemDisposalModeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOrderServiceItemDisposalModeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOrderServiceItemDisposalModeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "CONSTRUCTION_AND_INSTALLATION,EQUIPMENT_WARRANTY,SITE_ACCEPTANCE,OVERTIME_ON_SITE,OTHER", example = "CONSTRUCTION_AND_INSTALLATION")
    public String getCode() {
        return this.name();
    }

}
